Machine learning detection of database injection attacks

ABSTRACT

Techniques and solutions are described for detecting malicious database activity, such as SQL injection attempts. A first machine learning classifier can be trained by comparing processed and unprocessed user input, where a difference between the two can indicate suspicious or malicious activity. The trained classifier can be used to analyze user input before query execution. A second machine learning classifier is trained with a data set that includes call stack information for an application requesting execution of a dynamic query and query statistics associated with processing of the query at the database. The query of the application can be correlated with a corresponding database query by hashing the application query and the database query and comparing the hash values, where matching hash value indicate a common query. The trained classifier can monitor execution of future queries to identify queries having anomalous patterns, which may indicate malicious or suspicious activity.

FIELD

The present disclosure generally relates to database security.Particular implementations relate to automatically detecting securityattacks, such as command injection attacks, using machine learningtechniques.

BACKGROUND

Databases are ubiquitous, from small databases that might service anapplication running on a mobile computing device, to enormous databasesthat are used in transaction processing and enterprise resource planningfor large corporate entities. Databases can be local to a particularmachine or computing system, or can be remote, such as cloud-baseddatabase systems. Particularly given the nature of information stored ina database, including sensitive information such as social securitynumbers, passwords, and financial information, databases are a primetarget for malicious activity.

While various techniques exist to reduce the susceptibility of adatabase system, or an application that uses databases services, toattack, users may be unaware of such techniques, or such techniques maynot be used, including because of time and cost pressures in softwaredevelopment. Further, attackers are also aware of techniques being usedto thwart their attacks, and may develop new attack methods for which acountermeasure has not yet been designed. Accordingly, room forimprovement exists.

SUMMARY

This Summary is provided to introduce a selection of concepts in asimplified form that are further described below in the DetailedDescription. This Summary is not intended to identify key features oressential features of the claimed subject matter, nor is it intended tobe used to limit the scope of the claimed subject matter.

Techniques and solutions are described for detecting malicious databaseactivity, such as SQL injection attempts. A first machine learningclassifier can be trained by comparing processed and unprocessed userinput, where a difference between the two can indicate suspicious ormalicious activity. The trained classifier can be used to analyze userinput before query execution. A second machine learning classifier istrained with a data set that includes call stack information for anapplication requesting execution of a dynamic query and query statisticsassociated with processing of the query at the database. The query ofthe application can be correlated with a corresponding database query byhashing the application query and the database query and comparing thehash values, where matching hash value indicate a common query. Thetrained classifier can monitor execution of future queries to identifyqueries having anomalous patterns, which may indicate malicious orsuspicious activity.

In one embodiment, a method is provided for detecting malicious databaseactivity, such as a SQL injection attempt. User input is received for afirst dynamic query. The user input is escaped to produce escaped userinput. A first version of the first dynamic query is formed by addingthe user input to a dynamic query language statement. A second versionof the first dynamic query is formed by adding the escaped user input tothe dynamic query language statement.

The first version of the first dynamic query is parsed and tokenized toobtain a first set of tokens. The second version of the first dynamicquery is parsed and tokenized to obtain a second set of tokens. Thefirst and second sets of tokens are compared. It is determined whetherthe first and second sets of tokens are equal. A training label isgenerated indicating whether the user input may be associated with asecurity violation. A machine learning component is trained with theuser input and the training label to, at least in part, provide atrained classifier. Test user input can be submitted to the trainedclassifier to determine if the test user input may be associated with apotential security violation.

In a further aspect, another method is provided for detecting maliciousdatabase activity, such as a SQL injection attempt. Call stackinformation is received from an application requesting execution of afirst dynamic query. A first index value associated with the firstdynamic query is received from the application. A second index value,associated with a second dynamic query, is received from a databasesystem. Query statistics associated with the second dynamic query arereceived from the database system. The first and second index values arecompared. Based on the comparing, it is determined that the firstdynamic query and the second dynamic query are the same query. A machinelearning component is trained with the call stack information and thequery statistics to, at least in part, provide a trained classifier. Thetrained classifier can be used to determine whether a third dynamicquery may be associated with an attempted security violation.

According to another method of detecting malicious database activity,such as a SQL injection attempt, call stack information is received froman application requesting execution of a first dynamic query. Querystatistics associated with the second dynamic query are received from adatabase system. It is determined that the first dynamic query and thesecond dynamic query are the same query. A machine learning component istrained with the call stack information and the query statistics to, atleast in part, provide a trained classifier. The trained classifier canbe used to determine whether a third dynamic query may be associatedwith an attempted security violation.

The present disclosure also includes computing systems and tangible,non-transitory computer readable storage media configured to carry out,or including instructions for carrying out, an above-described method.As described herein, a variety of other features and advantages can beincorporated into the technologies as desired.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram illustrating a scenario where a dynamic queryis used for a SQL injection attack.

FIG. 2 is a schematic diagram of a computing environment in whichdisclosed technologies can be implemented.

FIG. 3 is a diagram illustrating how malicious user input for a dynamicquery can be analyzed by comparing tokens for queries using escaped andnon-escaped user input.

FIG. 4 illustrates formats in which tokens can be provided for anexample query.

FIG. 5 is a diagram illustrating how malicious dynamic queries can bedetected by correlating application related information for a query withdatabase information for a corresponding query to be executed at adatabase system.

FIG. 6 is a diagram illustrating how a machine learning classifierresult can be used to continue normal query processing or take actionbased on a suspected or detected malicious query.

FIGS. 7-9 are flowcharts illustrating example operations for detectingmalicious database activity.

FIG. 10 is a diagram of an example computing system in which somedescribed embodiments can be implemented.

FIG. 11 is an example cloud computing environment that can be used inconjunction with the technologies described herein.

DETAILED DESCRIPTION Example 1—Overview

Databases are ubiquitous, from small databases that might service anapplication running on a mobile computing device, to enormous databasesthat are used in transaction processing and enterprise resource planningfor large corporate entities. Databases can be local to a particularmachine or computing system, or can be remote, such as cloud-baseddatabase systems. Particularly given the nature of information stored ina database, including sensitive information such as social securitynumbers, passwords, and financial information, databases are a primetarget for malicious activity.

While various techniques exist to reduce the susceptibility of adatabase system, or an application that uses databases services, toattack, users may be unaware of such techniques, or such techniques maynot be used, including because of time and cost pressures in softwaredevelopment. Further, attackers are also aware of techniques being usedto thwart their attacks, and may develop new attack methods for which acountermeasure has not yet been designed. Accordingly, room forimprovement exists.

One particular type of security attack is command injection, such as SQLinjection. Similar attacks can be mounted in languages other than SQL,including NoSQL, and in other contexts, such as operating system (OS)command injection and Lightweight Directory Access Protocol (LDAP)injection. The present disclosure generally discusses SQL injectionattacks for illustrative purposes, but the disclosed technologies can beused in other types of command injection scenarios.

In a SQL attack, a malicious user tries to insert malicious SQL codeinto a dynamic SQL statement. A dynamic SQL statement is a statementwhich is not entirely known at design time. In contrast, a static SQLstatement is one where all factors are known at design time.

As an example, a report that returns all records with an attribute valueabove a certain threshold can be written as a static SQL statement.Although the records that might be returned may change over time, allthe parameters needed to execute the SQL statement are known at designtime and can be hard coded into the SQL statement. Other types ofdatabase operations may involve parameters that are not known untilruntime. For example, a report template may retrieve data for aparticular user. However, the particular user might be any user, andthus the exact identify of the user is not known at design time. Atruntime, a user might wish to run a report for users with the first name“Udo,” or the first name “Ina.” Although the majority of the queryoperations may be known, a value corresponding to the identity of theuser is not known until the query is to be executed.

To make the example more concrete, consider the SQL statement:SELECT*FROM TABLE1 WHERE userID=‘X’. In this case, most of the SQLoperations are known, including the operators (e.g., SELECT, FROM) andcertain operands (e.g., *, TABLE1). However, this SQL statement isdynamic, in that it that includes a variable X, whose value will not beknown until the query is to be executed at runtime, and whose value canchange each time the SQL statement is executed. A first execution maysupply the value of “Udo” for X, and the next execution may supply thevalue of “Ina” for X.

A scenario 100 of FIG. 1 illustrates how dynamic queries can be used tocompromise a database system. The scenario 100 involves a databasesystem (such as a relational database management system, or RDBMS) 110that executes a dynamic SQL statement 114. The dynamic SQL statement 114is configured to receive two variables 118 at runtime. Once thevariables 118 are supplied, the database system 110 executes the dynamicSQL statement 114.

The scenario 100 further includes a first client system 122 thatincludes a first client application 124, and a second client system 128that includes a second client application 130. The first client system122 can be associated with a “legitimate” user, and the second clientsystem 128 can be associated with a “malicious” user. The first andsecond client applications 124, 130 supply values for the variables 118in the dynamic SQL statement 114. Typically, the first and second clientapplications 124, 130 will generate the dynamic SQL statement 114 andsend the statement to the database system 110 for execution. However, insome implementations, a client application 124, 130 can supply variablevalues to the database system 110, which can complete and execute thedynamic SQL statement 114.

When the scenario 100 is operating as expected, the first clientapplication 124 sends legitimate, expected values for the variables 118in the dynamic SQL statement 114. These values are processed to provideexpected execution results 134. However, when values are provided by thesecond client application 130, execution of the dynamic SQL statement114 can cause a security breach, and unexpected behavior 138. Theunexpected behavior can take various forms, including providing themalicious user with database administrator privileges, adding improperdata, deleting data, improperly updating data, or retrieving data forwhich the malicious user does not have access rights.

Often, SQL injections are carried out when values received for a dynamicquery deviate from an expected format, and the application does notadequately check the user input to determine if it is proper. An exampleof how a SQL injection attack, consider the dynamic query above:SELECT*FROM TABLE1 WHERE userID=‘X’. The variable X is intended torepresent a single name or other identifier, and to only containalphabetical characters. If a user instead supplies a value of “’OR1=1;”, the resulting query might be formed from simple stringconcatenation or otherwise, to produce the query: SELECT*FROM TABLE 1WHERE userID=‘ ’ OR 1=1. In this case, the malicious user might beprovided with the entire contents of TABLE1. This is a fairly simpleexample, and actual SQL injection attacks can be much more complex, anddamaging.

Good programming practices can help limit SQL injection vulnerabilities.For example, the second client application 130 may analyze user input todetermine that it complies with an expected format prior to forming thedynamic SQL statement 114, or sending it to the database system 110 forexecution. In this case, if the presence of non-alphabetic characters,such as the quote or equality sign, was detected, an error could bethrown and the dynamic SQL statement 114 not generated or executed.Another way of reducing the opportunities for SQL injection is to writea parameterized statement, where variable portions of a dynamicstatement are indicated with markers, and the value to be used areinserted after a SQL processor has prepared the statement. That is, theSQL processor will process the input as a literal, rather than as SQLcode. However, as mentioned, good programming practices are not alwaysfollowed, and so additional steps can be taken to enhance security.

One such additional step is the process of user input escaping. Escapingis a process of indicating that certain characters in a string are partof the string and should not be interpreted as code or commands. Forexample, in the case of a user name of “O'Conner,” it may not be clearwhether the “’” character is part of the input string or should beinterpreted as code, particularly when concatenated into a remainingportion of a dynamic SQL statement.

Typically, a database system or language (e.g., a query language)includes special characters that can be used to indicate that textfollowing the symbol is part of the user input. In the example above, anescaped version of the user name might be “O\'Conner.” The “\” n frontof the quote indicates that the quote is part of the string. That is,the “\” is an escape character, where an escape character is a characterthat invokes, such as acting as a flag or a switch, for differentmethods of interpreting one or more other characters in a sequence (inthis case, indicating whether the characters are part of a stringliteral or whether characters can potentially be interpreted ascode/commands).

In some cases, escaping can be performed by the client application 124,130. In other cases, escaping can be performed by the database system110 or another component. Furthermore, in at least some cases, a querycan be “unescaped” to try and reconstitute an original query or originaluser input. However, it may be difficult in particular instances todetermine which portions of a query correspond to user input and whichmay be part of the “base” dynamic query. Rules or templates can bedeveloped, for example, for at least some situations, such as forparticular applications (e.g., particular operands for particularoperators are designated as user input fields for a particularapplication).

Unfortunately, not all variables 118 supplied to a dynamic SQL statement114 are escaped. In some cases, a client application 124, 130 or adatabase system 110 may not perform escaping. Or, escaping may beincomplete or otherwise not capable of addressing all possible ways aSQL injection attack might be mounted. Further, in some cases escapingmight be undesirable, including due to the potential for data loss. Insome cases, for example, an escape character or string might part oflegitimate user input, and escaping might change the meaning of theinput, such as inserting an extra “I” into a URL.

The present disclosure provides technologies that can be used toautomatically detect query language statements that may include a SQLinjection attack, or otherwise represent malicious code. In a firstmethod, a machine learning technique is trained by comparing twoversions of a query language statement. A version is created that usesprocessed user input, such as user input processed using parameter (oruser input) escaping, and a version is created that is not processed,such as not being escaped. Tokens, and optionally relationships betweentokens, produced by the two versions are compared. Comparison caninclude a token-by-token comparison, or calculating hash values of setsof tokens, with a SQL injection attempt implicated if different hashvalues are produced. If the versions differ, a SQL injection attempt canbe presumed, and the query, or a portion thereof (e.g., the user input,the pattern of escaping, tokens included in the query and their order)can be used (as part of a machine learning model) to analyze test data(e.g., data to be classified using the trained classifier).

In another aspect, a machine learning technique is trained to recognize“normal” database behavior. Queries that deviate from “normal” operationcan be flagged as potential SQL injection attempts. The method caninclude correlating application execution information with databaseexecution information for a common query. The application executioninformation for a particular query can be correlated with the databaseexecution information for the query by obtaining hash values for queriessubmitted by the application and hash values for queries executed by adatabase system. A hash value of application database statement matchinga hash value of a database statement to be executed on the database canindicate that the queries are the same, as so characteristics of thequery can be correlated to train a classifier, or to detect a potentialSQL injection attempt using a trained classifier.

Application execution information can include information associatedwith a call stack for the application, and optionally other information.For example, the call stack can include identifiers of subroutines thatwere called, indications of where/how the subroutines were called,values of local variables, parameters passed to the subroutine, as wellas information regarding the ordering of the call stack. Other types ofapplication information can be included in the application executioninformation, such as an identifier of a client on which the applicationis running, an identifier of a particular user, or an identifier of aparticular user role (e.g., whether the user is a business user or adatabase administrator). Database execution information can include alist of tokens in the database statement, identities of tables accessed,query execution statistics (e.g., a number of tables accessed, a numberof records processed, a number of records returned, execution time,memory use, nodes involved in statement execution), or query executionplan information (e.g., operators in a logical plan or a physical plan).If the application execution information and the database executioninformation, including their combination or correlation, are indicatedas outliers, or match a pattern known to be associated with maliciouscode, an injection attempt can be indicated.

In both aspects, the performance of a classifier can be improved basedon user feedback. That is, a user can indicate that a database statementthat was indicated as a potential injection attempt was in factmalicious, or whether it was a false positive. Similarly, a user canprovide an indication of whether a database statement that was notflagged as potentially malicious was a false negative.

If a database statement is identified as potentially malicious, variousactions can be taken. In some cases, a query or input source (e.g., aparticular user, application, or client) can be monitored. If asufficient number of statements are received (in some cases, a singlestatement) from the source that are indicated as potentially malicious,or non-routine, additional action can be taken. Other actions that canbe taken, including after monitoring, include returning fake results inresponse to the database statement, disconnecting the user, session, orclient, providing an alert (e.g., to a security specialist or databaseadministration), not executing the query, and combinations of suchactions.

The disclosed technologies can provide various advantages. The disclosedtechnologies can improve database security, including by accommodatingthe use of applications that might not adhere to coding “bestpractices,” or where the “best practices” might be insufficient to guardagainst a particular attack. The improvements in database security canbe realized in an automated manner, reducing the need for humaninvolvement, and potentially the possibility of human error. However,human input can be used to improve the accuracy of the automatedtechniques.

Example 2—Example Computing Environment

FIG. 2 is a block diagram illustrating an example computing environment200 in which disclosed technologies can be implemented. In the computingenvironment 200, a client system 210 may communicate with a databasesystem 214 to execute queries. In some cases, the client system 210 andthe database system 214 may be part of a common computing system,including being operated on common computing components. In other cases,the client system 210 and the database system 214 are separate systems,but are in communication, such as through a physical connection or overa network connection. In particular examples, the client system 210 andthe database system 214 are connected over the internet, including usingweb (e.g., ftp, http, https) based services.

The client system 210 includes at least one application 218 thatrequests services from the database system 214. The services can includeretrieving data, updating data, adding data, and removing data. Theapplication 218 typically communicates with the database system 214using a query language, such as the structured query language (SQL).

Although the application 218 is shown as communicating directly with thedatabase system 214, the client system 210 or the database system 214,or both, may include one or more intermediate layers or frameworks thatmediate and facilitate communication between the client system and thedatabase system. For example, an application layer or server mayfacilitate interaction of the application 218 with the database system214, including by integrating query languages with other languages, suchas C++ or ABAP, or by abstracting details of the database system 214from the application 218, so that the application can be adapted fordifferent database systems. In particular, an intermediate layer caninclude a data dictionary that maps objects (e.g., instances of abstractdata types, or tables defined in the intermediate layer) to data(typically in tables) in the database system 214. Similarly, althoughnot shown, one or more additional computing systems may be intermediatethe client system 210 and the database system 214.

As explained in Example 1, the application 218 can use one or both ofstatic query language statements (or queries) or dynamic query languagestatements (or queries). The disclosed technologies are primarilyfocused on dynamic query language statements, and so the application 218is shown as including a dynamic SQL statement 222. The dynamic SQLstatement 222 is shown as accepting values 232 for two variables 226.Although two variables 226 are shown, it should be appreciated that aparticular dynamic SQL statement 222 can include a larger or smallernumber of variables. In addition, in some cases, at least some of thevariables 226 can be optional.

The values 232 for the variables 226 are typically provided by userinput 230, but can also be provided by the application 218, a differentapplication, or another computing process. The user input 230 can bereceived through a user interface 234. The user interface 234 can acceptthe user input 230 through various means, including text entry fields,selection boxes, drop down menus, value pickers, and the like. Wheninput is provided by another application, the input can be providedthrough an interface, such as an API, or similar techniques.

In some cases, the application 218 can perform one or more input checks238 on the user input 230. For example, if a variable 226 is torepresent a phone number, the user input checks 238 can determinewhether the user input 230 includes the correct number of digits, andonly digits. Similarly, for a variable 226 that represents a first orlast name, the user input checks 238 can determine whether the userinput 230 includes only alphabetical characters, or punctuation marksthat might be expected in a name, such as a period, comma, or anapostrophe. If a user input check 238 fails, in some cases, the userinput 230 can be reformatted to comply with rules for the user input. Inother cases, such as if the user's intent cannot be determined, the userinput 230 can be rejected by the application 218. The application 218can provide an error message, optionally including a source of the error(e.g., “too many characters,” “non-permitted character included”). Ifthe user input checks 238 pass, the user input 230 can be added to thedynamic SQL statement 222. The dynamic SQL statement 222 can then besent to the database system 214 for execution.

As explained in Example 1, in some cases, the user input checks 238 arenot included for a particular application 218. Or, the user input checks238 may not be sufficient to catch all errors in user input, or to catchall deliberate attempts to use the dynamic SQL statement 222 as anattack vector. Disclosed techniques, explained in further Examples,provide methods for detecting query language injection attacks when userinput checks 238 are not included, or are inadequate.

Prior to forming the dynamic SQL statement 222 for submission to thedatabase system 214, the user input 230 can be escaped by an escapingcomponent 242. The escaping component 242 can determine characters inthe user input 230 that might affect the interpretation of the dynamicSQL statement 222, and can include identifiers, escape characters, thatindicate that the determined characters are part of the user input 230and should be processed by the database system 214, such as by a queryprocessor 246, as values for the variables 226, and not to interpret thecontent as SQL commands. Once the user input 230 has been escaped, itcan be used to construct an executable version of the dynamic SQLstatement 222 that is then sent to the database system 214 forexecution.

As explained in Example 1, in some cases, an application 218 may notinclude an escaping component 242, the escaping component may not beused for particular user input 230, or the escaping component may beinadequate to identify all characters, including combinations ofcharacters, that should be escaped, or otherwise modified to guardagainst a query language injection attack. For any particularapplication 218 or user input 230, none, one, or both of user inputchecks 230 and processing by the escaping component 242 can be used. Asan example of how the escaping component 242 may different than, orcomplementary to, the user input checks 238, in some cases, user input230 may not fit a specific pattern such that it is known whetherparticular characters or combinations of characters might representlegitimate input. For instance, in some circumstances, user input 230might appropriately include characters such as forward or backwardslashes, ampersands, semicolons, quotation marks, and the like. A URI,including a URL for a website, is an example of user input that mightlegitimately include characters that might be reserved characters inquery language, or which might otherwise be used to change the meaningof the dynamic SQL statement 222. In such cases, the application 218 can“assume” that the user input 230 is correct/intentional/legitimate, butthe escaping component 242 can help ensure that the user input 230 isprocessed as such and does not otherwise affect the interpretation andexecution of the dynamic SQL statement 222.

At the database system 214, the dynamic SQL statement 222 can beprocessed by the SQL processor 246. The SQL processor 246 can beresponsible for parsing the dynamic SQL statement 222, generating aquery plan, overseeing query execution, and returning query results tothe application 218. Although shown as a single component, the SQLprocessor 246 can represent multiple components of the database system214.

The computing environment 200 can include additional components tofacilitate various aspects of the disclosed technologies. For example,in some cases, malicious activity detection can be facilitated bycomparing query execution data from the client system 210 and thedatabase system 214. In order to help to correlate data between theclient system 210 and the database system 214, the client system caninclude a hash generator 250 and the database system 214 can include ahash generator 252. The hash generators 250, 252 can use any suitablehash algorithm, including the MD5 hash or the SHA1 hash. However, atleast for a particular class of queries, applications, etc., the hashgenerators 250, 252 use the same hash functions so that hash values canbe compared. Although referred to as hash generators, the hashgenerators 250, 252 can, in some cases, more generally be indexgenerators, and may generate an index value other than a hash value,such as values for a skiplist index, a bitmap index, a B-tree index, aGiST (generalized search tree) index, or a GIN (generalized invertedindex) index.

As will be further described, a query language statement can bedetermined to be the same between the application 218 and the databasesystem 214 when queries on the two systems have matching hash values. Insome cases, additional information may be used to correlate queriesbetween the application 218 and the database system 214, such as havingthe queries be at least partially contemporaneous (e.g., so data from anearlier execution of a query is not mixed with data from a laterexecution of the query).

Similarly, the client system 210 and the database system 214 can includerespective parser/tokenizing components 256, 258. The parser/tokenizingcomponents 256, 258 can be used to decompose the dynamic query languagestatement 222 into its constituent operators and operands. The tokenizedquery language statement can then be provided to other components of theclient system 210 or the database system 214, such as to respectiveinjection detection components 262, 264. The injection detectioncomponents 262, 264 can be in communication with various othercomponents of the computing environment 200.

The injection detection components 262, 264 can include respectiveclassifier components 268, 270. The classifier components 268, 270 canreceive data for training purposes or test purposes. The classifiers268, 270 can be based on any suitable, desired machine learningapproach, including supervised and unsupervised methods. Example machinelearning techniques include deep neural networks, nearest neighbor,n-nearest neighbor, Bayesian techniques, probabilistic techniques,support vector machines, decisions tree, and k-means clustering.

In a particular aspect, the client system 210 can include a call stackmonitor 274. The call stack monitor 274 can acquire various informationabout subroutines running on the client system 210, includingsubroutines of the application 218. Information acquired by the callstack monitor 274 can include subroutine identifiers, local variablevalues, a return address, and parameter values passed to a particularsubroutine. The call stack information can be provided to othercomponents of the computing environment 200, including the injectiondetection components 262, 264, such as for use with the classifiercomponents 268, 270. Alternatively, or additionally, call stackinformation can be provided by another component, such as theapplication 218 or an operating system 276.

The client system 210 and the database system 214 can include respectivesecurity components 278, 280. The security components 278, 280 can takevarious actions when malicious action is detected, as will be furtherdescribed. For the database system 214, communication with clientsystems, including the client system 210, can be mediated by a sessionmanager 284. If malicious activity is detected or suspected, thesecurity component 280 can cause the session manager 284 to disconnect asession associated with the client system 210.

It should be appreciated that the computing environment 200 can includemore, fewer, or different components than shown. Further, functionsdescribed as carried out by one component can be carried out by multiplecomponents, or functions can be combined in a single component or in adifferent combination of components than described.

Example 3—Example Machine Learning Using Processed and Unprocessed UserInput

FIG. 3 illustrates an example scenario 300 for detecting query languageinjection attempts. The scenario 300 can include components described inthe computing environment 200 of FIG. 2. For example, the operations ofthe scenario 300 can be carried out in the client system 210. As will bedescribed, the scenario 300 detects query language injection attempts bycomparing tokens produced by parsing and tokenizing a version of a queryproduced with processed user input, such as escaped user input, withtokens produced by parsing and tokenizing a version of a query producedwith unprocessed, such as non-escaped, user input.

User input 310 is obtained, and is provided to a first process 314 andto a second process 318. The second process 318 uses an un-escapedversion of the user input to complete a dynamic query languagestatement. The user input 310 is provided to a query builder 322 toproduce a dynamic query 326. The query builder 322 can operate invarious manners, and can be a component that is used for “normal”application operation. That is, the query builder 322 can be a componentthat would exist even in the absence of the disclosed techniques.

The dynamic query 326 can be provided to parser/tokenizer component 330to provide tokens 334. All or a portion of the tokens 334 can be passedto a comparator 338, which compares the provided tokens with tokensreceived from the first process 314. The tokens 334 can be passed to thecomparator 338 in various formats, including as a simple unstructuredlist or set of tokens (although the tokens can be in an order, such asan execution order or an order in which the tokens appear in the dynamicquery 326). In other cases, the tokens 334 can be provided in a way thatprovides additional information regarding the dynamic query 326, such asin way than maintains associations between operators, or betweenoperators and operands. In a particular example, the tokens 334 can beprovided in the form of a parse tree.

FIG. 4 illustrates examples of output that can be produced by theparser/tokenizer component 330 for an example query 400. Output can beprovided in the form of a list 410 of tokens 414, where the tokens caninclude operators 418 and operands 422. Although described as a list410, the tokens 414 can be provided in any suitable data structure(e.g., a queue, tree, vector, stack, heap, graph, etc.). Output can alsobe provided in the form of a parse tree 426, where the parse tree has ahierarchical structure and includes relationships between operators 418,and between operators and operands 422. The parse tree, or otherdescription of relationships between tokens 414, can be maintained in asuitable data structure, such as a tree, graph, or heap.

Returning to FIG. 3, in the first process 314, the user input 310 isprovided to an escaping component 342. The escaping component 342produces escaped user input that is provided to the query builder 322 toproduce a dynamic query 346. The dynamic query 346 is provided to theparser/tokenizer 330 to provide tokens 350, at least a portion of whichare provided to the comparator 338, including in a similar manner asdescribed for the tokens 334.

The comparator 338 compares the tokens 334 with the tokens 350, whichcan include determining whether the tokens 334 and 350 are the same, aswell as whether they are arranged in a manner that provides the samesemantic meaning. A label, such as “good” or “bad,” “yes,” or “no”, orsimilar labels, can be assigned as the result 354 of the comparison,indicating whether the tokens 334, 350 are the same, and thus whetherthe user input 310 may represent malicious activity. The comparison canbe a token-by-token comparison, a comparison of tokens and theirinterrelationships, or some other comparison. The comparison can also bebased on a summary or digest of the tokens, such as by comparing a hashvalue for the tokens 334 with a hash value for the tokens 350.

The result 354 can be provided to a machine learning component 358,which can be used, at least in part to train the machine learningcomponent 358 to provide a classifier, or to act as further training toan established classifier. The machine learning component 358 can beprovided with other information to help guide a classification result,including one or more of the user input 310, the dynamic queries 326,346, or the tokens 334, 350 (and associated information, such asrelationships between tokens). Other information can be provided to themachine learning component 358, including identifiers of a clientassociated with the user input 310, an application associated with theuser input, a user ID associated with the user input, or a user roleassociated with the user input.

In some cases, the label applied by the comparator 338 to the result 350serves as an identified classification for training data. That is, ifthe result is “no match,” the user input 310 is determined to bemalicious. In other cases, the label applied to the result 354 serves astraining data, but the label of “malicious” or “not” is applied inanother way, such as being manually applied or as a result of detectingthe malicious activity in another manner.

The user input 310 is also associated with the result 354, andoptionally other information about the tokens 334, 350 or dynamicqueries 326, 346, for the machine learning component 358. Thus, themachine learning component 358 will associate particular user input witha particular result. With test data, as opposed to training data, theuser input 310 can be provided to the trained machine learning component358. The trained machine learning component 358 can provide anindication of whether the user input 310 is likely associated withmalicious activity. If not, the user input 310 can be processednormally. If the indication is that the user input 310 may be malicious,other actions can be taken, as will be further described in Example 5.

In some cases, the scenario 300 is carried out by a client system. Inother cases, a client system can communicate with another computingdevice, such as a database system, in performing the scenario 300. Forexample, the user input 310 and dynamic query shell can be provided tothe database system, such as via an API or RFC. The database system canreturn the classification result to the client computing system, andboth the database system and the client computing system, or any one ofthem, can take appropriate action if a query language injection attemptis detected or suspected.

In some cases, the scenario 300 is particularly useful when a clientsystem performs user input escaping, which provides data that can beused to train a machine learning component to provide a classifier.However, the scenario 300 can be used, or adapted, for other use casescenarios. For example, a technique similar to the scenario 300 can beimplemented at a database system, where the database system treats allor certain operands as user input and escapes them. A parser/tokenizercomponent can determine portions of a dynamic query that are more orless likely to have resulted from user input. A join condition, forexample, may less likely to be associated with user input than a valuefor a WHERE operator. Or, the nature of a user, query, client system, orapplication may influence a ruleset used to infer what types of valuesmight be associated with user input. The scenario 300, as well as othermalicious activity detection techniques, including that discussed inExample 4, might only be applied against certain types of queries,including queries from particular users, user types, client systems, orapplications.

Example 4—Example Machine Learning Using Correlated Application andDatabase Information

FIG. 5 illustrates another scenario 500 for detecting query languageinjection attempts. Like the scenario 300, the scenario 500 can becarried out using various components described for the computingenvironment 200 of FIG. 2. In practice, one, or both, of the scenarios300 and 500 can be used. The scenario 500 may be particularly usefulwith user input escaping is not performed. Rather than using comparisonsbetween queries resulting from escaped/unescaped user input, thescenario 500 determines patterns associated with “normal” queries, suchthat a query having a different pattern can be identified as potentiallymalicious. The scenario 500 combines data associated with the query at aclient system with data associated with the query at a database system.In order to provide this combination/correlation, the scenario 500includes techniques for correlating a query at the client system with acounterpart query at the database system.

The scenario 500 is shown as carried out by a client system 504, adatabase system 508, and an injection detection component 510. Althoughshown as a separate components, in some cases the injection detectioncomponent 510 can be combined with the client system 504 or the databasesystem 508.

The client system 504 includes one or more call stacks 514, such as acall stack associated with a particular application. The client system504 may maintain one or more call stacks for each application 516executing on the client system. The call stacks 514 may be maintained byvarious components of the client system 504, depending on the particularcall stack. For example, an application server or framework (such as aframework providing a virtual machine) may maintain a call stack 514, anoperating system can maintain a call stack, or a separate call stackmonitoring component can be executing on the client system 504.Different components of the client system 504 can maintain a call stackfor an application, and such call stacks can include differentinformation. For instance, a call stack 514 maintained by an operatingsystem may be more detailed than a call stack maintained by a frameworkor a monitoring component.

The client system 504 can include additional application information 518for applications 516. The additional information can include anapplication identifier, an identifier of the client system 504, anidentifier for a user of the client application, or an identifier of auser role (e.g., database administrator, data entry operator) associatedwith a user.

The client system 504 can take user input 520 and process it, in aprocess 522, to produce a dynamic query 524. The process 522 can besimilar the user input processing described in conjunction with thecomputing environment 200 of FIG. 2, and so details are not provided inFIG. 5 for clarity of presentation. The dynamic query 524 is hashed toprovide a query hash value (or other index value) 526, which is providedto the injection detection component 510, typically with otherinformation, such as the dynamic query, tokens associated with thedynamic query (optionally with associated sematic or structuralinformation), information associated with the dynamic query in the callstack 514, and application information 518. For instance, the injectiondetection component 510 may be sent the identities of subroutines on thecall stack 514 when execution of a dynamic query was initiated, theidentity of a subroutine that called for query execution, or anidentifier associated with the application. The injection detectioncomponent 510 can be sent other information, such as the identity of auser who issues the query request, a user role associated with the user,and information about other user activity, such as a number of otherqueries executed by the user and optionally information associated withsuch queries (including an indication of whether the other queries werebenign or were suspected of malicious activity).

As an example of how a classifier can identify suspicious or maliciousactivity in the scenario 500, a normal operation for a particularapplication might be to join a phone list with a list of addresses. If aquery included an operation to join the phone list with the databasecatalog, it could be detected as an anomalous query. Similarly, if aparticular query pattern would normally retrieve a single result, and aquery with a similar query pattern (e.g., list of tokens, arrangement oftokens, query execution plan, etc.) would retrieve one million results,it could be detected as an anomalous query. Anomalous queries may alsobe indicated by querying a table, or pattern of tables, that was notqueried before, or has token or token semantics (e.g., relationships toother tokens) that do not match typical sets of tokens or query pattern.

The dynamic query 524 is also sent from the client system 504 to thedatabase system 508. The database system 508 takes various actions toexecute the dynamic query 524, such as generating a query execution plan530, which can be associated with various statistics 534 or otherinformation (e.g., operators for a logical or physical plan). Thestatistics 534 can include a number of tables accessed, the identitiesof tables accessed, a number of records to be processed, a result size,an estimated execution time, and estimated resource use (e.g., amount ofmemory used, number of network communications, processor time, etc.).The statistics 534 can also include information such as a queryexecution plan, including a logical plan, a physical plan, or both. Aswith query tokens, operators and other content associated with a queryexecution plan can be provided in the form of a list, or in a structure,such as a tree, that maintains relationships between elements. Thestatistics 534 can be provided to the injection detection component 510,as will be further described.

Like the client system 504, the database system 508 can calculate a hashvalue (or other index value) 538 for the dynamic query 524. The hashvalue 538 can be provided to the injection detection component 510. Theinjection detection component 510 can determine at 542 whether a hashvalue 526 matches a hash value 538. If a match is detected, theinjection detection component 510 can process the information receivedfrom the client system 504 and the database system 508 to determinewhether a query may be associated with a query language injectionattempt, wherein information associated with a common hash value (andoptionally other information, such as temporal information) is combined.Although described as being used to process test data, the injectiondetection component 510 can perform analogous actions for training data.For example, the injection detection component 510 can be allowed to“observe” queries for a period of time for training purposes. Once theinjection detection component 510 is sufficiently trained, such as torecognize “normal” patterns, it can start to classify queries.

At 546, the injection detection component 510 can process the statistics534 received from the database system 508, in some cases, to extract orformat the information, to provide formatted information 550, such astokens forming the query, including in the forms shown in FIG. 4, tablesaccessed by the query, a result size, etc., which is then provided to amachine learning classifier 554. However, more, less, or differentinformation can be provided to the machine learning classifier 554, invarious implementations.

The machine learning classifier 554 uses the formatted information 550,and the information from the call stack 514, to provide a result 556.Typically, the result 556 is a label of “yes” or “no,” “good,” or “bad,”“suspicious,” or “benign,” or a similar binary classification. Theresult 556 can be provided to the database system 508, where, at 558,the database system can proceed to forward the query to a query executor562 if the query is benign. If the query is suspicious, the databasesystem 508 provides a notification to a security component 566 as aresult of the determining at 558. The security component 566 can thentake various actions, such as further described in Example 5. Similarly,if the result 556 indicates a potentially malicious query, the resultcan be provided to a security component 568 of the client system 504,which can then take appropriate action.

Example 5—Example Actions Based on Classification Result

FIG. 6 illustrates example operations 600 for processing user input or aquery formed therefrom to determine whether it represents an attemptedquery language injection, and corresponding actions that can be takendepending if user input or query is identified as potentially malicious.The operations 600 be associated with any of the scenarios 300, 500 ofFIGS. 3 and 5, and can be carried out in the computing environment 200of FIG. 2.

A machine learning classifier produces a classification result at 604,such as using the operations of scenario 300 or scenario 500. Forexample, at 606 user input can be received. The user input can beprovided to a classifier 608 trained according to Example 3 to providethe classification result 604. Or, at 610, application information anddatabase information for a query can be provided to a classifier 612trained according to Example 5 to provide the classification result 604.

At 616, if the result indicates that the query is benign, user inputassociated with the query is optionally escaped at 618. The user inputis used at 620 to build a dynamic query 622, which is executed at 624 toprovide query results 628. The query results 624 are then returned, suchas to an application of a client system, at 630. In some cases, such asin the scenario 500, the dynamic query 620 may be already been formedprior to analysis by the machine learning component at 604. In thisevent, the operations 600 can proceed from 616 to 624.

If it is determined at 616 that a query may be associated with anattempted query language injection, one or more actions can be taken.The one or more actions can be carried out exactly as shown, such asprescribing a particular action or combination for any potentiallymalicious query, or the actions can be specified in rules for specifictypes of queries, applications, users, user roles, or other parameters.That is, different actions in response to a potentially malicious queryor user input may be taken depending on the nature of the application,user role, etc.

In some cases, determining a potentially malicious query at 616 canresult in generating an alert at 632. The alert 632 can be an indicationissued to a user, such as a database administrator, a securityprofessional, or a combination thereof. The alert can be in the form ofan audio or visual display of information, including an informationdisplay provided by email, text message, instant message, or an alert inan application user interface display. As another action, in response todetermining a potentially malicious query at 616, query execution can beterminated at 636. Terminating at 636 can also generate a message, suchas to a user who submitted the query, indicating that the query is notbeing executed, and optionally that suspicious activity has beendetected.

In some cases, it may be useful to monitor activity associated with apotentially malicious user. In this case, in response to determining apotential attack at 616, fake query results can be provided at 640. Thequery results 640 can be results having a format consistent withexecution results of the dynamic query, so that a user is not alerted tothe detection of suspicious activity, or that that the query results arenot accurate. After providing the fake query results at 640, otheractions can be taken, such as monitoring further activity by the user.As another option, if malicious activity is detected or suggested at616, an application, database session, or both, associated with thesource of the potentially malicious query can be terminated at 644.

The actions shown in FIG. 6 are by way of example only, and otheractions, or combinations of actions, may be taken. For example, if themalicious activity is occurring in association with an applicationprocess, that application process can be terminated, or a database canblock further requests associated with that process. In another example,activity associated with a particular user, client, or application canbe monitored (and perhaps an alert generated, as in 632) once suspiciousactivity is detected. Further actions may not be taken immediately, butmay be taken if repeated suspicious activity is detected. For example,if a user issues X number of suspicious queries over Y time period, thequeries may be aborted, a database session terminated, an alertgenerated, etc. Rules can be configured that determine what actions aretaken based on a number of detected suspicious queries, including overdifferent time periods (e.g., 2 suspicious queries over 10 minutesversus over 2 hours).

Whether, or what, action is taken can also depend on other factors, suchas a particular application that is requesting a query, a particularuser that is requesting a query, or a particular user role that isassociated with the query. Particular types of users, such as a databaseadministrator, may execute longer running, more complex, or more dataintensive queries than typical end users. So, particularly using thetechnique of Example 4, activity that might be anomalous for typical endusers may be acceptable if it is associated instead with a databaseadministrator or someone else with a non-standard or typical user role.A query issued by a database administrator might be anomalous comparedwith “normal” users simply because it is an administrative query ratherthan, say, an ERP related query. Based on a user role, the actions 634,636, 640, 644 may not be taken, or queries from a user having the rolemay not be analyzed using the technologies of Example 3 or of Example 4.

Example 6—Example Query Analysis Operations

FIG. 7 is a flowchart of an example method 700 of detecting maliciousdatabase activity, such as a SQL injection attempt. The method 700 canbe performed, in some examples, using the computing environment 200 ofFIG. 2. At 704, user input is received for a first dynamic query. Theuser input is processed, such as being escaped, at 708 to produceprocessed, such as escaped, user input. At 712, a first version of thefirst dynamic query is formed by adding the user input to a dynamicquery language statement. A second version of the first dynamic query isformed at 716 by adding the escaped user input to the dynamic querylanguage statement.

At 720, the first version of the first dynamic query is parsed andtokenized to obtain a first set of tokens. The second version of thefirst dynamic query is parsed and tokenized at 724 to obtain a secondset of tokens. The first and second sets of tokens are compared at 728.It is determined at 732 whether the first and second sets of tokens areequal. At 736, a training label is generated indicating whether the userinput may be associated with a security violation. A machine learningcomponent is trained at 740 with the user input and the training labelto, at least in part, provide a trained classifier. Test user input canbe submitted to the trained classifier to determine if the test userinput may be associated with a potential security violation.

FIG. 8 is a flowchart of an example method 800 of another disclosedembodiment of detecting malicious database activity, such as a SQLinjection attempt. The method 800 can be performed, in some examples,using the computing environment 200 of FIG. 2. At 804, call stackinformation is received from an application requesting execution of afirst dynamic query. A first index value associated with the firstdynamic query is received from the application at 808. At 812, a secondindex value, associated with a second dynamic query, is received from adatabase system. Query statistics associated with the second dynamicquery are received from the database system at 816. The first and secondindex values are compared at 820. Based on the comparing, at 824, it isdetermined that the first dynamic query and the second dynamic query arethe same query. At 828, a machine learning component is trained with thecall stack information and the query statistics to, at least in part,provide a trained classifier. The trained classifier can be used todetermine whether a third dynamic query may be associated with anattempted security violation.

FIG. 9 is a flowchart of an example method 900 of a further disclosedembodiment of detecting malicious database activity, such as a SQLinjection attempt. The method 900 can be performed, in some examples,using the computing environment 200 of FIG. 2. At 904, call stackinformation is received from an application requesting execution of afirst dynamic query. Query statistics associated with the second dynamicquery are received from a database system at 908. At 912, it isdetermined that the first dynamic query and the second dynamic query arethe same query. A machine learning component is trained at 916 with thecall stack information and the query statistics to, at least in part,provide a trained classifier. The trained classifier can be used todetermine whether a third dynamic query may be associated with anattempted security violation.

Example 7—Computing Systems

FIG. 10 depicts a generalized example of a suitable computing system1000 in which the described innovations may be implemented. Thecomputing system 1000 is not intended to suggest any limitation as toscope of use or functionality of the present disclosure, as theinnovations may be implemented in diverse general-purpose orspecial-purpose computing systems.

With reference to FIG. 10, the computing system 1000 includes one ormore processing units 1010, 1015 and memory 1020, 1025. In FIG. 10, thisbasic configuration 1030 is included within a dashed line. Theprocessing units 1010, 1015 execute computer-executable instructions,such as for implementing components of the computing environment 200 ofFIG. 2, including as described in Examples 1-6. A processing unit can bea general-purpose central processing unit (CPU), processor in anapplication-specific integrated circuit (ASIC), or any other type ofprocessor. In a multi-processing system, multiple processing unitsexecute computer-executable instructions to increase processing power.For example, FIG. 10 shows a central processing unit 1010 as well as agraphics processing unit or co-processing unit 1015. The tangible memory1020, 1025 may be volatile memory (e.g., registers, cache, RAM),non-volatile memory (e.g., ROM, EEPROM, flash memory, etc.), or somecombination of the two, accessible by the processing unit(s) 1010, 1015.The memory 1020, 1025 stores software 1080 implementing one or moreinnovations described herein, in the form of computer-executableinstructions suitable for execution by the processing unit(s) 1010,1015.

A computing system 1000 may have additional features. For example, thecomputing system 1000 includes storage 1040, one or more input devices1050, one or more output devices 1060, and one or more communicationconnections 1070. An interconnection mechanism (not shown) such as abus, controller, or network interconnects the components of thecomputing system 1000. Typically, operating system software (not shown)provides an operating environment for other software executing in thecomputing system 1000, and coordinates activities of the components ofthe computing system 1000.

The tangible storage 1040 may be removable or non-removable, andincludes magnetic disks, magnetic tapes or cassettes, CD-ROMs, DVDs, orany other medium which can be used to store information in anon-transitory way and which can be accessed within the computing system1000. The storage 1040 stores instructions for the software 1080implementing one or more innovations described herein.

The input device(s) 1050 may be a touch input device such as a keyboard,mouse, pen, or trackball, a voice input device, a scanning device, oranother device that provides input to the computing system 1000. Theoutput device(s) 1060 may be a display, printer, speaker, CD-writer, oranother device that provides output from the computing system 1000.

The communication connection(s) 1070 enable communication over acommunication medium to another computing entity. The communicationmedium conveys information such as computer-executable instructions,audio or video input or output, or other data in a modulated datasignal. A modulated data signal is a signal that has one or more of itscharacteristics set or changed in such a manner as to encode informationin the signal. By way of example, and not limitation, communicationmedia can use an electrical, optical, RF, or other carrier.

The innovations can be described in the general context ofcomputer-executable instructions, such as those included in programmodules, being executed in a computing system on a target real orvirtual processor. Generally, program modules or components includeroutines, programs, libraries, objects, classes, components, datastructures, etc. that perform particular tasks or implement particularabstract data types. The functionality of the program modules may becombined or split between program modules as desired in variousembodiments. Computer-executable instructions for program modules may beexecuted within a local or distributed computing system.

The terms “system” and “device” are used interchangeably herein. Unlessthe context clearly indicates otherwise, neither term implies anylimitation on a type of computing system or computing device. Ingeneral, a computing system or computing device can be local ordistributed, and can include any combination of special-purpose hardwareand/or general-purpose hardware with software implementing thefunctionality described herein.

In various examples described herein, a module (e.g., component orengine) can be “coded” to perform certain operations or provide certainfunctionality, indicating that computer-executable instructions for themodule can be executed to perform such operations, cause such operationsto be performed, or to otherwise provide such functionality. Althoughfunctionality described with respect to a software component, module, orengine can be carried out as a discrete software unit (e.g., program,function, class method), it need not be implemented as a discrete unit.That is, the functionality can be incorporated into a larger or moregeneral purpose program, such as one or more lines of code in a largeror general purpose program.

For the sake of presentation, the detailed description uses terms like“determine” and “use” to describe computer operations in a computingsystem. These terms are high-level abstractions for operations performedby a computer, and should not be confused with acts performed by a humanbeing. The actual computer operations corresponding to these terms varydepending on implementation.

Example 8—Cloud Computing Environment

FIG. 11 depicts an example cloud computing environment 1100 in which thedescribed technologies can be implemented. The cloud computingenvironment 1100 comprises cloud computing services 1110. The cloudcomputing services 1110 can comprise various types of cloud computingresources, such as computer servers, data storage repositories,networking resources, etc. The cloud computing services 1110 can becentrally located (e.g., provided by a data center of a business ororganization) or distributed (e.g., provided by various computingresources located at different locations, such as different data centersand/or located in different cities or countries).

The cloud computing services 1110 are utilized by various types ofcomputing devices (e.g., client computing devices), such as computingdevices 1120, 1122, and 1124. For example, the computing devices (e.g.,1120, 1122, and 1124) can be computers (e.g., desktop or laptopcomputers), mobile devices (e.g., tablet computers or smart phones), orother types of computing devices. For example, the computing devices(e.g., 1120, 1122, and 1124) can utilize the cloud computing services1110 to perform computing operators (e.g., data processing, datastorage, and the like).

Example 9—Implementations

Although the operations of some of the disclosed methods are describedin a particular, sequential order for convenient presentation, it shouldbe understood that this manner of description encompasses rearrangement,unless a particular ordering is required by specific language set forthbelow. For example, operations described sequentially may in some casesbe rearranged or performed concurrently. Moreover, for the sake ofsimplicity, the attached figures may not show the various ways in whichthe disclosed methods can be used in conjunction with other methods.

Any of the disclosed methods can be implemented as computer-executableinstructions or a computer program product stored on one or morecomputer-readable storage media, such as tangible, non-transitorycomputer-readable storage media, and executed on a computing device(e.g., any available computing device, including smart phones or othermobile devices that include computing hardware). Tangiblecomputer-readable storage media are any available tangible media thatcan be accessed within a computing environment (e.g., one or moreoptical media discs such as DVD or CD, volatile memory components (suchas DRAM or SRAM), or nonvolatile memory components (such as flash memoryor hard drives)). By way of example, and with reference to FIG. 10,computer-readable storage media include memory 1020 and 1025, andstorage 1040. The term computer-readable storage media does not includesignals and carrier waves. In addition, the term computer-readablestorage media does not include communication connections (e.g., 1070).

Any of the computer-executable instructions for implementing thedisclosed techniques as well as any data created and used duringimplementation of the disclosed embodiments can be stored on one or morecomputer-readable storage media. The computer-executable instructionscan be part of, for example, a dedicated software application or asoftware application that is accessed or downloaded via a web browser orother software application (such as a remote computing application).Such software can be executed, for example, on a single local computer(e.g., any suitable commercially available computer) or in a networkenvironment (e.g., via the Internet, a wide-area network, a local-areanetwork, a client-server network (such as a cloud computing network), orother such network) using one or more network computers.

For clarity, only certain selected aspects of the software-basedimplementations are described. It should be understood that thedisclosed technology is not limited to any specific computer language orprogram. For instance, the disclosed technology can be implemented bysoftware written in C, C++, C #, Java, Perl, JavaScript, Python, Ruby,ABAP, SQL, XCode, GO, Adobe Flash, or any other suitable programminglanguage, or, in some examples, markup languages such as html or XML, orcombinations of suitable programming languages and markup languages.Likewise, the disclosed technology is not limited to any particularcomputer or type of hardware.

Furthermore, any of the software-based embodiments (comprising, forexample, computer-executable instructions for causing a computer toperform any of the disclosed methods) can be uploaded, downloaded, orremotely accessed through a suitable communication means. Such suitablecommunication means include, for example, the Internet, the World WideWeb, an intranet, software applications, cable (including fiber opticcable), magnetic communications, electromagnetic communications(including RF, microwave, and infrared communications), electroniccommunications, or other such communication means.

The disclosed methods, apparatus, and systems should not be construed aslimiting in any way. Instead, the present disclosure is directed towardall novel and nonobvious features and aspects of the various disclosedembodiments, alone and in various combinations and sub combinations withone another. The disclosed methods, apparatus, and systems are notlimited to any specific aspect or feature or combination thereof, nor dothe disclosed embodiments require that any one or more specificadvantages be present or problems be solved.

The technologies from any example can be combined with the technologiesdescribed in any one or more of the other examples. In view of the manypossible embodiments to which the principles of the disclosed technologymay be applied, it should be recognized that the illustrated embodimentsare examples of the disclosed technology and should not be taken as alimitation on the scope of the disclosed technology. Rather, the scopeof the disclosed technology includes what is covered by the scope andspirit of the following claims.

What is claimed is:
 1. A method, implemented in a computing systemcomprising one or more processors and one or more memories coupled tothe one or more processors, the one or more memories comprisingcomputer-executable instructions for causing the computing system toperform operations comprising: receiving user input for a first dynamicquery, the user input comprising one or more characters; escaping theuser input to provide escaped user input, the escaping comprising addingat least one character to the one or more characters to indicate that atleast one character of the one or more characters corresponds to userinput, the escaped user input comprising the one or more characters ofthe user input and the at least one character; forming a first versionof the first dynamic query by adding the user input to a dynamic querylanguage statement comprising a plurality of query language operatorsand executable by a database system to provide first query results;forming a second version of the first dynamic query by adding theescaped user input to the dynamic query language statement, the secondversion of the first dynamic query comprising the plurality of querylanguage operators and executable by the database system to providesecond query results, wherein the second query results are the firstquery results or are different than the first query results; parsing andtokenizing the first version of the first dynamic query to obtain afirst set of tokens; parsing and tokenizing the second version of thefirst dynamic query to obtain a second set of tokens; comparing thefirst and second set of tokens; determining whether the first and secondsets of tokens are equal based on the comparing; generating a traininglabel based on the determining, the training label indicating whetherthe user input may be associated with an attempted security violation;and training a machine learning component with the user input and thetraining label to, at least in part, provide a trained classifier,wherein the trained classifier is usable to determine whether a seconddynamic query may be associated with an attempted security violation. 2.The method of claim 1, further comprising: receiving test user input;submitting the test user input to the trained classifier; receiving aclassification result; and taking at least one action based on theclassification result.
 3. The method of claim 2, wherein theclassification result indicates that the test user input is notassociated with an attempted security violation and the at least oneaction comprises: generating the second dynamic query using the testuser input; executing the second dynamic query; and returning queryexecution results for the second dynamic query.
 4. The method of claim2, wherein the classification result indicates that the test user inputmay be associated with an attempted security violation and the at leastone action comprises: not executing the second dynamic query based onthe test user input.
 5. The method of claim 2, wherein theclassification result indicates that the test user input may beassociated with an attempted security violation and the at least oneaction comprises: returning fake query results in response to the testuser input.
 6. The method of claim 2, wherein the classification resultindicates that the test user input may be associated with an attemptedsecurity violation and the at least one action comprises: disconnectinga network connection associated with the user.
 7. The method of claim 2,wherein the classification result indicates that the test user input maybe associated with an attempted security violation and the at least oneaction comprises: generating an electronic alert; and sending theelectronic alert to a designated contact.
 8. The method of claim 1,where escaping the user input comprises: searching the user input forone or more designated characters; determining that at least one of theone or more designated characters are present in the user input; andinserting at least one character into the user input, the at least onecharacter indicating that the at least one of the one or more designatedcharacters are part of the user input.
 9. The method of claim 1, whereintraining the machine learning component comprises training the machinelearning component with a set comprising the user input, the traininglabel, and the dynamic query language statement.
 10. A computing systemcomprising: memory; one or more processing units coupled to the memory;and one or more non-transitory computer readable storage media storinginstructions that, when executed, cause the computing system to performoperations comprising: receiving user input for a first dynamic query,the user input comprising one or more characters; escaping the userinput to provide escaped user input, the escaping comprising adding atleast one character to the one or more characters to indicate that atleast one character of the one or more characters corresponds to userinput, the escaped user input comprising the one or more characters ofthe user input and the at least one character; forming a first versionof the first dynamic query by adding the user input to a dynamic querylanguage statement comprising a plurality of query language operatorsand executable by a database system to provide first query results;forming a second version of the first dynamic query by adding theescaped user input to the dynamic query language statement, the secondversion of the first dynamic query comprising the plurality of querylanguage operators and executable by the database system to providesecond query results, wherein the second query results are the firstquery results or are different than the first query results; parsing andtokenizing the first version of the first dynamic query to obtain afirst set of tokens; parsing and tokenizing the second version of thefirst dynamic query to obtain a second set of tokens; comparing thefirst and second set of tokens; determining whether the first and secondsets of tokens are equal based on the comparing; generating a traininglabel based on the determining, the training label indicating whetherthe user input may be associated with an attempted security violation;and training a machine learning component with the user input and thetraining label to, at least in part, provide a trained classifier,wherein the trained classifier is usable to determine whether a seconddynamic query may be associated with an attempted security violation.11. The computing system of claim 10, the operations further comprising:receiving test user input; submitting the test user input to the trainedclassifier; receiving a classification result; and taking at least oneaction based on the classification result.
 12. The computing system ofclaim 11, wherein the classification result indicates that the test userinput is not associated with an attempted security violation and the atleast one action comprises: generating the second dynamic query usingthe test user input; executing the second dynamic query; and returningquery execution results for the second dynamic query.
 13. The computingsystem of claim 10, wherein the classification result indicates that thetest user input may be associated with an attempted security violationand the at least one action comprises: not executing the second dynamicquery based on the test user input.
 14. The computing system of claim11, wherein the classification result indicates that the test user inputmay be associated with an attempted security violation and the at leastone action comprises: returning fake query results in response to thetest user input.
 15. The computing system of claim 11, wherein theclassification result indicates that the test user input may beassociated with an attempted security violation and the at least oneaction comprises: disconnecting a network connection associated with theuser.
 16. The computing system of claim 11, wherein the classificationresult indicates that the test user input may be associated with anattempted security violation and the at least one action comprises:generating an electronic alert; and sending the electronic alert to adesignated contact.
 17. The computing system of claim 10, where escapingthe user input comprises: searching the user input for one or moredesignated characters; determining that at least one of the one or moredesignated characters are present in the user input; and inserting atleast one character into the user input, the at least one characterindicating that the at least one of the one or more designatedcharacters are part of the user input.
 18. The computing system of claim10, wherein training the machine learning component comprises trainingthe machine learning component with a set comprising the user input, thetraining label, and the dynamic query language statement.
 19. One ormore non-transitory computer-readable storage media comprising:computer-executable instructions that, when executed by a computingsystem comprising at least one hardware processor and at least onememory coupled to the at least one hardware processor, cause thecomputing system to receive user input for a first dynamic query, theuser input comprising one or more characters; computer-executableinstructions that, when executed by the computing system, cause thecomputing system to escape the user input to provide escaped user input,the escaping comprising adding at least one character to the one or morecharacters to indicate that at least one character of the one or morecharacters corresponds to user input, the escaped user input comprisingthe one or more characters of the user input and the at least onecharacter; computer-executable instructions that, when executed by thecomputing system, cause the computing system to form a first version ofthe first dynamic query by adding the user input to a dynamic querylanguage statement comprising a plurality of query language operatorsand executable by a database system to provide first query results;computer-executable instructions that, when executed by the computingsystem, cause the computing system to form a second version of the firstdynamic query by adding the escaped user input to the dynamic querylanguage statement, the second version of the first dynamic querycomprising the plurality of query language operators and executable bythe database system to provide second query results, wherein the secondquery results are the first query results or are different than thefirst query results; computer-executable instructions that, whenexecuted by the computing system, cause the computing system to parseand tokenize the first version of the first dynamic query to obtain afirst set of tokens; computer-executable instructions that, whenexecuted by the computing system, cause the computing system to parseand tokenize the second version of the first dynamic query to obtain asecond set of tokens; computer-executable instructions that, whenexecuted by the computing system, cause the computing system to comparethe first and second set of tokens; computer-executable instructionsthat, when executed by the computing system, cause the computing systemto determine whether the first and second sets of tokens are equal basedon the comparing; computer-executable instructions that, when executedby the computing system, cause the computing system to generate atraining label based on the determining, the training label indicatingwhether the user input may be associated with an attempted securityviolation; and computer-executable instructions that, when executed bythe computing system, cause the computing system to train a machinelearning component with the user input and the training label to, atleast in part, provide a trained classifier, wherein the trainedclassifier is usable to determine whether a second dynamic query may beassociated with an attempted security violation.